package com.evil.application.pojo.dto.robot;

import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.application.dto.robot.RobotSourceDTO;
import com.evil.common.application.enums.robot.RobotFirstTriggerTypeEnum;
import com.evil.common.core.enums.SwitchEnum;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * 应用高级机器人执行 请求实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class AppRobotActionReqDTO {

    /**
     * 触发类型
     */
    @NotNull(message = "triggerTypeEnum not null")
    private RobotFirstTriggerTypeEnum triggerTypeEnum;

    /**
     * 机器人源类型
     */
    @NotNull(message = "source not null")
    private RobotSourceDTO source;

    /**
     * 订单id
     */
    @NotNull(message = "orderId not null")
    private Long orderId;

    /**
     * 订单数据
     */
    @NotNull(message = "data not null")
    private List<ControlDataDTO> data;

    /**
     * 原订单数据
     */
    @NotNull(message = "oldData not null")
    private List<ControlDataDTO> oldData;

    /**
     * 应用key
     */
    @NotBlank(message = "applicationKey not null")
    private String applicationKey;

    /**
     * 记录应用层级
     */
    private List<String> logAppKeys;

    /**
     * 是否是同步
     */
    private Integer sync;

    public AppRobotActionReqDTO() {
        this.data = new ArrayList<>();
        this.oldData = new ArrayList<>();
        this.logAppKeys = new ArrayList<>();
        this.sync = SwitchEnum.NO.getId();
    }

    public AppRobotActionReqDTO setApplicationKey(String applicationKey) {
        this.applicationKey = applicationKey;
        this.logAppKeys.add(this.applicationKey);
        return this;
    }
}
